package com.epro.dx.task;

import java.util.ArrayList;

import com.epro.dx.listenner.MyAsyncTaskListenner;
import com.epro.dx.util.ActivityUtil;
import com.weipu.common.facade.exception.DxException;
import com.weipu.common.facade.factory.ProviderFactory;

import android.content.Context;
import android.os.AsyncTask;

/************************
 * @author Tony
 * @Date:2016-5-3上午11:25:19
 * @描述:设置消息已读任务
 ************************/
public class SetNoticeReadAsyncTask extends BaseNeedReLoginTask {

	private MyAsyncTaskListenner myAsyncTaskListenner;
	private int actionType;
	private ArrayList<String> noticeIDs;
	private boolean setNoticeRead;
	private Context mContext;
	public SetNoticeReadAsyncTask(Context mContext,int actionType,ArrayList<String> noticeIDs,MyAsyncTaskListenner myAsyncTaskListenner){
		this.mContext = mContext;
		this.actionType = actionType;
		this.noticeIDs = noticeIDs;
		this.myAsyncTaskListenner = myAsyncTaskListenner;
		
	}
	@Override
	protected void onPreExecute() {
		if(null!=myAsyncTaskListenner){
			myAsyncTaskListenner.onPreTask();
		}
		super.onPreExecute();
	}
	@Override
	protected String doInBackground(Void... params) {
		try {
			setNoticeRead = ProviderFactory.createMessageService().setNoticeRead(actionType, noticeIDs, ActivityUtil.getCustomerID(), ActivityUtil.getCustomerToken());
		} catch (DxException e) {
			return e.getErrCode();
		}
		return "0";
	}
	@Override
	protected void onPostExecute(String result) {
		super.onPostExecute(result);
		if(null!=myAsyncTaskListenner && !isRelogin){
			myAsyncTaskListenner.onPostTask(result, setNoticeRead);
		}
	}
	@Override
	protected Context setContext() {
		return mContext;
	}
	@Override
	protected BaseNeedReLoginTask setTask() {
		return new SetNoticeReadAsyncTask(mContext, actionType, noticeIDs, myAsyncTaskListenner);
	}

}
